<?php
/**
 * Created by PhpStorm.
 * User: yuanjie
 * Date: 15/12/14
 * Time: 下午4:44
 */
class WeChatPay
{
    const APP_ID = 'wx664e3e4c6b3b1267';
    const APP_SECRET = '688351e34b6b6b4a46e7bf3c32cdf8a9';

    /*
     * 获取微信token
     * 中控服务器应根据 expires_in 保存token
     * 控制统一刷新有效期
     * */
    public static function get_access_token(){
        $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='. WeChat::APP_ID .'&secret=' . WeChat::APP_SECRET;
        $response = Httpful::get($url)
            ->timeoutIn(5)
            ->sendsForm()->send();
        return $response;
    }
    
}